home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cuj1008.zip / RAMEY.ZIP / PSORT.MAN < prev    next >
Text File  |  1991-10-06  |  5KB  |  149 lines

  1. .in 5
  2. NAME
  3.  
  4. psort - sort the standard input file
  5.  
  6. SYNOPSIS
  7.  
  8. psort [-t <dir>] [-s <record size>]
  9.     [ [-k <keys>] ] [ [-f <range>] [-c <range>] ]...
  10.  
  11. DESCRIPTION
  12.  
  13. psort sorts lines of the standard input file and writes the result
  14. on the standard output.  Default key is the entire line.
  15. Default ordering is lexicographic by bytes in machine
  16. collating sequence.
  17.  
  18. .in +4
  19. .ti -4
  20. -t    use the following name for the temporary directory
  21. default is taken from environment variable %TMP%
  22.  
  23. .ti -4
  24. -s    if a single value is specified, use a fixed length record of
  25. the indicated number of bytes. If a range of sizes is specified,
  26. assume variable length records upto the maximum size in the range.
  27. Default is a variable length text record terminated by a newline character.
  28.  
  29. .ti
  30. -k    specify the collating sequence for the subsequently specified
  31. sorting fields.  The collating sequence is specified as one
  32. or more ranges of values.  Characters are assigned collating
  33. sequence in order of their specification.  For example,
  34. to sort lower case alphabetic characters use -k 'a'-'z'.
  35. Any characters not specified will be assigned a collating
  36. value of 0.  Characters in a field beyond a character with
  37. a 0 collating value will not be included within the sorted field.
  38. Hence, either of records b<0>a and b<0>c  may precede the other
  39. in the output file.
  40. Within a key specification, any number of ranges may be
  41. specified.  For example, if the sorting field will contain
  42. any combination of lower case letters, digits and spaces,
  43. use -k  ' ' '0'-'9' 'a'-'z'.  Spaces will sort before digits
  44. which will sort before lower case letters.  If no key
  45. collating sequence is specified,  a default collating
  46. sequence of all printable ascii characters is used.
  47.  
  48. .ti -4
  49. -r    repeat previous collating sequence.  For example, to fold
  50. upper case letters to lower case letters for purposes of
  51. determining sorting priority use -k 'a'-'z' -r 'A'-'Z'.
  52. This would assign the first character following the -r
  53. the same collating value as the first one assigned in the
  54. previous range.  To give varying white space characters equal
  55. weight use -k ' ' -r '\t' -r '_' .
  56.  
  57. .ti -4
  58. -n    numeric sort on the key.  This is an alternative to -k.
  59. numeric fields may contain a leading sign and/or decimal point.
  60. Numeric fields should look like
  61. [' ']...[+|-]['0'-'9']...[.]['0'-'9']...
  62. Any non-numeric characters will terminate the field.
  63. The field will be sorted by numeric value.
  64.  
  65. .ti -4
  66. -i    invert the sequence of the sort for the last key specified.
  67.  
  68. .ti -4
  69. -u    output only records that are unique according to the
  70.     sorting key fields.
  71.  
  72. .ti -4
  73. -f    sort on one or more fields.  Fields are groups of
  74. characters separated by a delimiter character.
  75. Fields are number starting at 0.  That is -f 0
  76. refers to the start of the record.
  77. A field specification may contain a range of
  78. fields as in -f 2-4 to indicate that sorting
  79. sequence is to be determined on the basis of
  80. the third, fourth and fifth fields in turn.
  81. A range must have a definite end.  ie -f 2-
  82. is not permited.  A field range need not
  83. be increasing.  ie -f 3-2 is permited and
  84. will sort first by the fourth then by the
  85. third field.
  86.  
  87. .ti -4
  88. -c    sort one or more characters within the indicated
  89. fields.  Start counting character positions from 0.
  90. For example -f 1 -c 2-3 would sort on the third and
  91. fourth characters of the second field.  Several
  92. character ranges may be specifed for a given field.
  93. For example -f 2 -c 5-6 -c 3-4 -c 1-2 would specify
  94. three sorting fields of 2 characters each with the
  95. third delimited field.  When specifying a character
  96. range within a field, the second number must be greater
  97. or larger than the first.  ie. -c 7-3 cannot be used.
  98. An indefinite character range can be specified as
  99. in -c 4- . This will indicate all characters starting
  100. with the fifth to the end of the field.
  101.  
  102. .ti -4
  103. <range>    a range is used to specify ranges of fields, displacements
  104. within a field and collating values.  The common syntax is
  105. <start>[-[<end>]] . <start> indicates a single value. <start>-
  106. indicates a range beginning at <start> to a large number.  For
  107. example -f 2- would be used to specify all fields after the
  108. second.  <start>-<end> indicates a range of fields.  The
  109. start and end number can be in a number of formats:
  110. simple decimal numbers, numbers starting with 0 are taken
  111. to be octal, numbers starting with 0x are taken to be
  112. hexidecimal and characters within apostrophes are converted
  113. to there ascii value.  Hence -k ' ' 'a'-'z' and -k 0x20 'a'-122
  114. are equivalent.
  115.  
  116. .ti -4
  117. -d    the following character is the field delimiter. For example
  118. -d '|' . The default field delimiter is a tab (0x09).
  119. .in -4
  120.  
  121. Sorting proceeds according to the precedence indicated by
  122. the sequence of the sorting fields.
  123. Records with the same sorting fields
  124. will be output in an unpredictable sequence.
  125.  
  126. Remember that characters not specified within a collating
  127. sequence are taken as collating value zero.
  128. This can result in unexpected behavior when fields
  129. are not the same length. Following is the result of
  130. sorting a small file with -k 'z'-'a'.
  131.  
  132. .nf
  133. def
  134. cad
  135. basdf
  136. a
  137. aa
  138.  
  139. .fi
  140. This was probably not the result intended.  To get the
  141. desired result, use -k 'a'-'z' -i.
  142.  
  143. .nf
  144. def
  145. cad
  146. basdf
  147. aa
  148. a
  149.